package services;

import dao.BookDao;
import utils.Book;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet("/showbook")
public class ShowBook extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        System.out.println("查询所有书籍...");
        BookDao bookDao = new BookDao();
        ArrayList<Book> list = bookDao.findAll();
        request.setAttribute("list",list);
        request.getRequestDispatcher("/index.jsp").forward(request,response);
    }
}
